/* This class will collect all non-persistent objects and attributes of the current simulation,
 * and combine them into an object to be pushed to a file for saving. After being reloaded,
 * this class will also re-integrate the stored attributes/objects into the running simulation. */

import java.util.*;
import java.io.Serializable;
import java.io.IOException;

public class SimState implements Serializable {
  
  private Vector animals;
  private int mapsize;
  private loc[][] wind;
  private int[][] temp;
  private int[][] land;
  private int[][] humid;
  private int[][] plant;
  private int[] sliders;//this is where the sliders are for the UI
  private double speed;
  private int sealevel; 
  private double sunlight; 
  private int humidity; 
  
  public static final SimState CaptureState() {
     Vector animals = AnimalHandlerObject.getAnimalVector();
     int mapsize = HeightMap.SIZE;
     loc[][] wind = WindMap.GetWindData();
     int[][] temp = TempMap.GetTempData();
     int[][] land = HeightMap.GetHeightMap();
     int[][] humid = HumidMap.GetHumidData();
     int[][] plant = PlantMap.GetPlantData();
     int slide[] = {SimulationConstants.mainUI.jSlider1.getValue(), SimulationConstants.mainUI.jSlider2.getValue(),SimulationConstants.mainUI.jSlider3.getValue(),SimulationConstants.mainUI.jSlider4.getValue()};
     double Tspeed = SimulationConstants.speed;
     int Tsealevel = SimulationConstants.sealevel;
     double Tsunlight = SimulationConstants.sunlight;
     int Thumid = SimulationConstants.humidity;
     return new SimState(animals,plant,land,temp,humid,wind,mapsize, slide, Tspeed, Tsealevel, Tsunlight, Thumid);
     }
  
  public SimState(Vector animals, int[][] plant, int[][] land, int[][] temp, int[][] humid, loc[][] wind, int mapsize, int[] sliders, double speed, int sealevel, double sunlight, int humid2) {
    this.animals = animals;
    this.plant = plant;
    this.wind = wind;
    this.temp = temp;
    this.land = land;
    this.humid = humid;
    this.mapsize = mapsize;
    this.sliders = sliders;//this is where the sliders are for the UI
    this.speed = speed;
    this.sealevel = sealevel; 
    this.sunlight = sunlight; 
    this.humidity = humid2;
    }
  
  public void SetState() {
    AnimalHandlerObject.setVector(animals);
    HeightMap.SetMapData(land);
    PlantMap.SetPlantData(plant);
    HumidMap.SetHumidData(humid);
    TempMap.SetTempData(temp);
    WindMap.SetWindData(wind);
    SimulationConstants.mainUI.jSlider1.setValue(sliders[0]);
    SimulationConstants.mainUI.jSlider2.setValue(sliders[1]);
    SimulationConstants.mainUI.jSlider3.setValue(sliders[2]);
    SimulationConstants.mainUI.jSlider4.setValue(sliders[3]);
    SimulationConstants.speed= speed;
    SimulationConstants.sealevel = sealevel; 
    SimulationConstants.sunlight = sunlight; 
    SimulationConstants.humidity = humidity;
  }
}